var todaycount = 0;
var qunzhong = 0;
var richang = 0;
var qunzhongtoday = 0;
var richangtoday = 0;
var zaihaidengji = [0, 0, 0, 0, 0];
var zaihaileixing = [0, 0, 0, 0, 0, 0, 0, 0, 0];
var qunzhongshangbao = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
var richangxuncha = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
var zongxinxishu = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
var yichuli = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
var alldata;
var alldataarr;
var qunzhongdataarr;
var richangdataarr;
$(document).ready(function () {

    $.ajax({
        url: "/recordDO/getAllRecord",
        type: 'GET',
        dataType: "json",
        success: function (data) {
            if (data.length > 0) {
                alldata = data;
                alldataarr = alldata;
                zuzhuang(data);
            }
        },
        error: function () {

        },

    });

});

function zuzhuang(data) {
    alldataarr = alldata;
    qunzhongdataarr = new Array;
    richangdataarr = new Array;

    for (var i = 0; i < data.length; i++) {
        if (isToday(data[i].createTime)) {
            todaycount++;
        }
        if (data[i].type == 0) {
            qunzhong++;
            qunzhongdataarr.push(data[i]);
            if (isToday(data[i].modifyTime)) {
                qunzhongtoday++;
            }
        } else {
            richangdataarr.push(data[i]);
            richang++;
            if (isToday(data[i].modifyTime)) {
                richangtoday++;
            }
        }

        if (data[i].hazardLevel == -1) {
            zaihaidengji[0]++;
        } else if (data[i].hazardLevel == 0) {
            zaihaidengji[1]++;
        } else if (data[i].hazardLevel == 1) {
            zaihaidengji[2]++;
        } else if (data[i].hazardLevel == 2) {
            zaihaidengji[3]++;
        } else if (data[i].hazardLevel == 3) {
            zaihaidengji[4]++;
        }


        if (data[i].hazardType == -1) {
            zaihaileixing[0]++;
        } else if (data[i].hazardType == 0) {
            zaihaileixing[1]++;
        }
        else if (data[i].hazardType == 1) {
            zaihaileixing[2]++;
        }
        else if (data[i].hazardType == 2) {
            zaihaileixing[3]++;
        }
        else if (data[i].hazardType == 3) {
            zaihaileixing[4]++;
        }
        else if (data[i].hazardType == 4) {
            zaihaileixing[5]++;
        }
        else if (data[i].hazardType == 5) {
            zaihaileixing[6]++;
        }
        else if (data[i].hazardType == 6) {
            zaihaileixing[7]++;
        }

        if (data[i].district == "城中区") {
            zongxinxishu[0]++;
            if (data[i].status == 1) {
                yichuli[0]++;
            }
            if (data[i].type == 0) {
                qunzhongshangbao[0]++;
            } else {
                richangxuncha[0]++
            }
        }
        else if (data[i].district == "鱼峰区") {
            zongxinxishu[1]++;
            if (data[i].status == 1) {
                yichuli[1]++;
            }
            if (data[i].type == 0) {
                qunzhongshangbao[1]++;
            } else {
                richangxuncha[1]++
            }
        }
        else if (data[i].district == "柳南区") {
            zongxinxishu[2]++;
            if (data[i].status == 1) {
                yichuli[2]++;
            }
            if (data[i].type == 0) {
                qunzhongshangbao[2]++;
            } else {
                richangxuncha[2]++
            }
        }
        else if (data[i].district == "柳北区") {
            zongxinxishu[3]++;
            if (data[i].status == 1) {
                yichuli[3]++;
            }
            if (data[i].type == 0) {
                qunzhongshangbao[3]++;
            } else {
                richangxuncha[3]++
            }
        }
        else if (data[i].district == "柳江区") {
            zongxinxishu[4]++;
            if (data[i].status == 1) {
                yichuli[4]++;
            }
            if (data[i].type == 0) {
                qunzhongshangbao[4]++;
            } else {
                richangxuncha[4]++
            }
        }
        else if (data[i].district == "柳城县") {
            zongxinxishu[5]++;
            if (data[i].status == 1) {
                yichuli[5]++;
            }
            if (data[i].type == 0) {
                qunzhongshangbao[5]++;
            } else {
                richangxuncha[5]++
            }
        }
        else if (data[i].district == "鹿寨县") {
            zongxinxishu[6]++;
            if (data[i].status == 1) {
                yichuli[6]++;
            }
            if (data[i].type == 0) {
                qunzhongshangbao[6]++;
            } else {
                richangxuncha[6]++
            }
        }
        else if (data[i].district == "融安县") {
            zongxinxishu[7]++;
            if (data[i].status == 1) {
                yichuli[7]++;
            }
            if (data[i].type == 0) {
                qunzhongshangbao[7]++;
            } else {
                richangxuncha[7]++
            }
        }
        else if (data[i].district == "融水县") {
            zongxinxishu[8]++;
            if (data[i].status == 1) {
                yichuli[8]++;
            }
            if (data[i].type == 0) {
                qunzhongshangbao[8]++;
            } else {
                richangxuncha[8]++
            }
        }
        else if (data[i].district == "三江县") {
            zongxinxishu[9]++;
            if (data[i].status == 1) {
                yichuli[9]++;
            }
            if (data[i].type == 0) {
                qunzhongshangbao[9]++;
            } else {
                richangxuncha[9]++
            }
        }


    }

    document.getElementById('count').innerText = data.length;
    document.getElementById('todaycount').innerText = todaycount;
    document.getElementById('qunzhong').innerText = qunzhong;
    document.getElementById('richang').innerText = richang;
    document.getElementById('qunzhongtoday').innerText = qunzhongtoday;
    document.getElementById('richangtoday').innerText = richangtoday;
    shuju();
}


function isToday(str) {
    if (new Date(str).toDateString() === new Date().toDateString()) {
        return true;
    } else if (new Date(str) < new Date()) {
        //之前
        return false;
    }
}


function shuju() {
    // 基于准备好的dom，初始化echarts实例
    var myChart1 = echarts.init(document.getElementById('Business_type'));
// 指定图表的配置项和数据
    option1 = {
        tooltip: {
            trigger: 'item',
            formatter: "{a} <br/>{b} : {c} ({d}%)"
        },
        legend: {
            x: 'center',
            y: 'bottom',
            data: ['未知', '不稳定滑坡', '滑坡', '崩塌', '泥石流', '地面塌陷', '地裂缝', '地面沉降'],
            textStyle: {
                color: '#4ADEFE',
            }
        },
        series: [
            {
                name: '灾害类型',
                type: 'pie',
                radius: ['30%', '55%'],
                center: ['45%', '35%'],
                avoidLabelOverlap: false,
                data: [
                    {value: zaihaileixing[0], name: '未知'},
                    {value: zaihaileixing[1], name: '不稳定滑坡'},
                    {value: zaihaileixing[2], name: '滑坡'},
                    {value: zaihaileixing[3], name: '崩塌'},
                    {value: zaihaileixing[4], name: '泥石流'},
                    {value: zaihaileixing[5], name: '地面塌陷'},
                    {value: zaihaileixing[6], name: '地裂缝'},
                    {value: zaihaileixing[7], name: '地面沉降'}
                ],
                itemStyle: {
                    emphasis: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            }
        ],
        color: ['#daf39d', '#009AFF', '#F77474', '#28DCCF', '#66ff6b', '#85ff4c', '#ff3c9e', '#ff1012']
    };
// 使用刚指定的配置项和数据显示图表。
    myChart1.setOption(option1);
    var myChart0 = echarts.init(document.getElementById('lefttop'));

// 指定图表的配置项和数据
    option0 = {
        tooltip: {
            trigger: 'item',
            formatter: "{a} <br/>{b} : {c} ({d}%)"
        },
        legend: {
            x: 'center',
            y: 'bottom',
            data: ['未知', '一般', '较大', '重大', '特大'],
            textStyle: {
                color: '#4ADEFE',
            }
        },
        series: [
            {
                name: '灾害等级',
                type: 'pie',
                radius: ['30%', '55%'],
                center: ['45%', '35%'],
                avoidLabelOverlap: false,
                data: [
                    {value: zaihaidengji[0], name: '未知'},
                    {value: zaihaidengji[1], name: '一般'},
                    {value: zaihaidengji[2], name: '较大'},
                    {value: zaihaidengji[3], name: '重大'},
                    {value: zaihaidengji[4], name: '特大'},
                ],
                itemStyle: {
                    emphasis: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            }
        ],
        color: ['#eceef3', '#1c85ff', '#dff726', '#dc6221', '#ff1f3d']
    };
// 使用刚指定的配置项和数据显示图表。
    myChart0.setOption(option0);


    var myChart2 = echarts.init(document.getElementById('Land_analysis'));

    option2 = {
        legend: {
            x: 'right',
            y: 'top',
            textStyle: {
                color: '#4ADEFE',
            }
        },
        grid: {
            x: 30,
            y: 50,
            x2: 0,
            y2: 45
        },
        tooltip: {},
        dataset: {
            source: [
                ['product', '群众上报', '日常巡查'],
                ['城中区', qunzhongshangbao[0], richangxuncha[0]],
                ['鱼峰区', qunzhongshangbao[1], richangxuncha[1]],
                ['柳南区', qunzhongshangbao[2], richangxuncha[2]],
                ['柳北区', qunzhongshangbao[3], richangxuncha[3]],
                ['柳江区', qunzhongshangbao[4], richangxuncha[4]],
                ['柳城县', qunzhongshangbao[5], richangxuncha[5]],
                ['鹿寨县', qunzhongshangbao[6], richangxuncha[6]],
                ['融安县', qunzhongshangbao[7], richangxuncha[7]],
                ['融水县', qunzhongshangbao[8], richangxuncha[8]],
                ['三江县', qunzhongshangbao[9], richangxuncha[9]],
            ]
        },
        xAxis: {
            type: 'category',
            axisLine: {
                show: false,
                lineStyle: {
                    color: "#4ADEFE",
                },
            },
            // data: ["岳阳市","益阳市","长沙市","株洲市","衡阳市","永州市","娄底市","郴州市","湘潭市"],
            axisTick: {
                alignWithLabel: true
            }
        },
        yAxis: {
            axisLine: {
                lineStyle: {
                    color: "#4ADEFE",
                }
            },
            splitLine: {
                lineStyle: {
                    color: '#4ADEFE'
                }
            }
        },
        series: [
            {
                type: 'bar',
                barMaxWidth: '10',
                itemStyle: {
                    normal: {
                        color: '#4ADEFE'
                    },
                },
            },
            {
                type: 'bar',
                barMaxWidth: '10',
                itemStyle: {
                    normal: {
                        color: '#F3DB5C',
                    },
                },
            }
        ]
    };
    myChart2.setOption(option2);

    var myChart3 = echarts.init(document.getElementById('Information_Delivery'));

    option3 = {
        legend: {
            x: 'right',
            y: 'top',
            textStyle: {
                color: '#4ADEFE',
            }
        },
        grid: {
            x: 30,
            y: 50,
            x2: 0,
            y2: 45
        },
        tooltip: {},
        dataset: {
            source: [
                ['product', '总信息数', '已处理数'],
                ['城中区', zongxinxishu[0], yichuli[0]],
                ['鱼峰区', zongxinxishu[1], yichuli[1]],
                ['柳南区', zongxinxishu[2], yichuli[2]],
                ['柳北区', zongxinxishu[3], yichuli[3]],
                ['柳江区', zongxinxishu[4], yichuli[4]],
                ['柳城县', zongxinxishu[5], yichuli[5]],
                ['鹿寨县', zongxinxishu[6], yichuli[6]],
                ['融安县', zongxinxishu[7], yichuli[7]],
                ['融水县', zongxinxishu[8], yichuli[8]],
                ['三江县', zongxinxishu[9], yichuli[9]],
            ]
        },
        xAxis: {
            type: 'category',
            axisLine: {
                lineStyle: {
                    color: "#4ADEFE",
                }
            }
        },
        yAxis: {
            axisLine: {
                lineStyle: {
                    color: "#4ADEFE",
                }
            },
            splitLine: {
                show: true,
                lineStyle: {
                    color: '#4ADEFE',
                }
            }
        },
        series: [
            {
                type: 'bar',
                barMaxWidth: '10',
                itemStyle: {
                    normal: {
                        color: '#4ADEFE'
                    },
                },
            },
            {
                type: 'bar',
                barMaxWidth: '10',
                itemStyle: {
                    normal: {
                        color: '#F3DB5C',
                    },
                },
            }
        ]
    };
    myChart3.setOption(option3);


    var myChart = echarts.init(document.getElementById('map'));
    showProvince(2, '#ff0000');
    myChart.on('click', function (params) {
        document.oncontextmenu = function () {
            return false;
        };
        if (params.name != "" && params.name != undefined) {
            document.getElementById("returnBtn").style.display = "block"; //隐藏

            document.oncontextmenu = function () {
                return false;
            };


            var xianqu = params.name.slice(0, 2)

            var xzongshu = 0;
            var xqunzhong = 0;
            var xrichang = 0;
            var xtodaycount = 0;
            var xqunzhongtoday = 0;
            var xrichangtoday = 0;
            var xzaihaidengji = [0, 0, 0, 0, 0];
            var xzaihaileixing = [0, 0, 0, 0, 0, 0, 0, 0, 0];

            alldataarr = new Array;
            qunzhongdataarr = new Array;
            richangdataarr = new Array;

            for (var j = 0; j < alldata.length; j++) {
                if (alldata[j].district.slice(0, 2) == xianqu) {
                    alldataarr.push(alldata[j]);

                    xzongshu++;
                    if (isToday(alldata[j].createTime)) {
                        xtodaycount++;
                    }
                    if (alldata[j].type == 0) {
                        qunzhongdataarr.push(alldata[j]);
                        xqunzhong++;
                        if (isToday(alldata[j].modifyTime)) {
                            xqunzhongtoday++;
                        }
                    } else {
                        richangdataarr.push(alldata[j]);
                        xrichang++;
                        if (isToday(alldata[j].modifyTime)) {
                            xrichangtoday++;
                        }
                    }
                    if (alldata[j].hazardLevel == -1) {
                        xzaihaidengji[0]++;
                    } else if (alldata[j].hazardLevel == 0) {
                        xzaihaidengji[1]++;
                    } else if (alldata[j].hazardLevel == 1) {
                        xzaihaidengji[2]++;
                    } else if (alldata[j].hazardLevel == 2) {
                        xzaihaidengji[3]++;
                    } else if (alldata[j].hazardLevel == 3) {
                        xzaihaidengji[4]++;
                    }

                    if (alldata[j].hazardType == -1) {
                        xzaihaileixing[0]++;
                    } else if (alldata[j].hazardType == 0) {
                        xzaihaileixing[1]++;
                    }
                    else if (alldata[j].hazardType == 1) {
                        xzaihaileixing[2]++;
                    }
                    else if (alldata[j].hazardType == 2) {
                        xzaihaileixing[3]++;
                    }
                    else if (alldata[j].hazardType == 3) {
                        xzaihaileixing[4]++;
                    }
                    else if (alldata[j].hazardType == 4) {
                        xzaihaileixing[5]++;
                    }
                    else if (alldata[j].hazardType == 5) {
                        xzaihaileixing[6]++;
                    }
                    else if (alldata[j].hazardType == 6) {
                        xzaihaileixing[7]++;
                    }


                }
            }

            document.getElementById('count').innerText = xzongshu;
            document.getElementById('todaycount').innerText = xtodaycount;
            document.getElementById('qunzhong').innerText = xqunzhong;
            document.getElementById('richang').innerText = xrichang;
            document.getElementById('qunzhongtoday').innerText = xqunzhongtoday;
            document.getElementById('richangtoday').innerText = xrichangtoday;

            option1.series[0].data = [
                {value: xzaihaileixing[0], name: '未知'},
                {value: xzaihaileixing[1], name: '不稳定滑坡'},
                {value: xzaihaileixing[2], name: '滑坡'},
                {value: xzaihaileixing[3], name: '崩塌'},
                {value: xzaihaileixing[4], name: '泥石流'},
                {value: xzaihaileixing[5], name: '地裂缝'},
                {value: xzaihaileixing[6], name: '地面沉降'}
            ]
            myChart1.setOption(option1);
            option0.series[0].data = [
                {value: xzaihaidengji[0], name: '未知'},
                {value: xzaihaidengji[1], name: '一般'},
                {value: xzaihaidengji[2], name: '较大'},
                {value: xzaihaidengji[3], name: '重大'},
                {value: xzaihaidengji[4], name: '特大'},
            ]
            myChart0.setOption(option0);
            var center = [109.256237, 24.995732];
            if (xianqu == '城中') {
                center = [109.461749, 24.362324];
            }
            else if (xianqu == '鱼峰') {
                center = [109.455364, 24.303848];
            }
            else if (xianqu == '柳南') {
                center = [109.195936, 24.357013];
            }
            else if (xianqu == '柳北') {
                center = [109.406577, 24.429145];
            }
            else if (xianqu == '柳江') {
                center = [109.234503, 24.167512];
            }
            else if (xianqu == '柳城') {
                center = [109.245812, 24.605121];
            }
            else if (xianqu == '鹿寨') {
                center = [109.740805, 24.483405];
            }
            else if (xianqu == '融安') {
                center = [109.403621, 25.214703];
            }
            else if (xianqu == '融水') {
                center = [109.051457, 25.336868];
            }
            else if (xianqu == '三江') {
                center = [109.502288, 25.74195];
            }


            myChart.setOption(option = {
                geo: {
                    center: center,
                    zoom: 1,
                    show: true,
                    map: xianqu,
                    mapType: xianqu

                },

            })
        }

    });

    $("#returnBtn").click(function () {
        $('#contextMenu').hide();
        document.getElementById("returnBtn").style.display = "none"; //隐藏
        myChart.setOption(option = {
            geo: {
                center: [109.256237, 24.995732],
                zoom: 1.2,
                show: true,
                map: '柳州',
                mapType: '柳州',

            },


        })

        $(".list_num1 span").text(yhd.length);
        $(".list_num2 span").text(yfq.length);
        $(".list_num3 span").text(wxrk);
        $(".circle_num1").text(wxcc);
        $(".circle_num2").text(wxh);
        $(".circle_num3").text(wxj);
        $(".circle_num4").text(ghfl);
        chuanzhi();

    });


    myChart.on('contextmenu', function (params) {
        $('#contextMenu').hide();
        document.getElementById("returnBtn").style.display = "none"; //隐藏
        myChart.setOption(option = {
            geo: {
                center: [109.256237, 24.995732],
                zoom: 1.2,
                show: true,
                map: '柳州',
                mapType: '柳州',

            },


        })


        shuju();
    });


    window.addEventListener("resize", function () {
        myChart.resize();
    });


}
function leijixq() {
    leiji(alldataarr, "累计上传记录详情");
}
function qunzhongxq() {
    leiji(qunzhongdataarr, "群众上报记录详情");
}
function richangxq() {
    leiji(richangdataarr, "日常巡查记录详情");
}


function showProvince(type, color) {


    if (type == 0) {
        $("#qz").prop("checked", true);
        $("#rc").prop("checked", false);
    } else if (type == 1) {
        $("#rc").prop("checked", true);
        $("#qz").prop("checked", false);
    }


    var myChart = echarts.init(document.getElementById('map'));
    var geoCoordMap = {};

    var mapdata = new Array;

    if (alldata.length > 0) {
        for (var i = 0; i < alldata.length; i++) {
            if (type == alldata[i].type) {

                var arr = alldata[i].positionData.split(',');
                var lng = arr[0].substring(5, arr[0].length);
                var lat = arr[1].substring(4, arr[1].length - 1);


                var mc = alldata[i].street;

                var string = "点" + i;
                geoCoordMap[string] = [lat, lng];

                var tempv = [50, mc];
                mapdata.push({name: string, value: tempv});
            }
        }


    }


    var size = 30;


    var max = 480,
        min = 0.1;
    var maxSize4Pin = 50,
        minSize4Pin = size; //红点图标大小
    var convertData = function (mapdata) {
        var res = [];
        for (var i = 0; i < mapdata.length; i++) {
            var geoCoord = geoCoordMap[mapdata[i].name];
            if (geoCoord) {
                res.push({
                    name: /*mapdata[i].name*/"",
                    value: geoCoord.concat(mapdata[i].value),
                });
            }
        }
        return res;
    };

    myChart.setOption(option = {
        tooltip: {
            trigger: 'item',
            formatter: function loadData(result) {
                return result.value[3];
            }
        },
        geo: {
            center: [109.256237, 24.995732],
            zoom: 1.2,
            show: true,
            map: '柳州',
            mapType: '柳州',
            label: {
                normal: {
                    show: true,
                    textStyle: {color: "#4bf316"}
                },
                emphasis: {
                    show: true,
                    textStyle: {
                        color: '#fff'
                    }
                },
            },
            roam: true,
            itemStyle: {
                normal: {
                    borderColor: 'rgba(147, 235, 248, 1)',
                    borderWidth: 2,
                    areaColor: {
                        type: 'radial',
                        x: 0.5,
                        y: 0.5,
                        r: 0.8,
                        colorStops: [{
                            offset: 0,
                            color: 'rgba(175,238,238, 0)' // 0% 处的颜色
                        }, {
                            offset: 1,
                            color: 'rgba(   47,79,79, .2)' // 100% 处的颜色
                        }],
                        globalCoord: false // 缺省为 false
                    },
                    shadowColor: 'rgba(128, 217, 248, 1)',
                    shadowOffsetX: -2,
                    shadowOffsetY: 2,
                    shadowBlur: 10
                },
                emphasis: {
                    areaColor: '#389BB7',
                    borderWidth: 0
                }
            }
        },
        series: [
            {
                name: '隐患点',
                type: 'scatter',
                coordinateSystem: 'geo',
                symbol: 'pin',
                symbolSize: function (val) {
                    var a = (maxSize4Pin - minSize4Pin) / (max - min);
                    var b = minSize4Pin - a * min;
                    b = maxSize4Pin - a * max;
                    return a * val[2] + b;
                },
                label: {
                    normal: {
                        formatter: '{b}',
                        show: true,
                        textStyle: {
                            color: '#fff',
                            fontSize: 10,
                        }
                    }
                },
                itemStyle: {
                    normal: {
                        color: color, //标志颜色
                    }
                },
                zlevel: 6,
                data: convertData(mapdata),
            },
            {
                type: 'effectScatter',
                coordinateSystem: 'geo',
                data: convertData(mapdata.sort(function (a, b) {
                    return b.value - a.value;
                }).slice(0, 47)),
                symbolSize: function (val) {
                    return val[2] / 10;
                },
                showEffectOn: 'render',
                rippleEffect: {
                    brushType: 'stroke'
                },
                hoverAnimation: true,
                itemStyle: {
                    normal: {
                        color: '#05C3F9',
                        shadowBlur: 10,
                        shadowColor: '#05C3F9'
                    }
                },
                zlevel: 1
            },

        ]
    });
}


function leiji(data, title) {
    layui.use('layer', function () {
        var layer = layui.layer;
        layer.open({
            type: 1,
            title: title,
            area: ['60%', '80%'],
            content: $('#showtable')
        });
    });
    layui.use('table', function () {
        var table = layui.table;
        //第一个实例
        table.render({
            elem: '#xq',
            cellMinWidth: 100,
            width: 1300
            , data: data
            , page: true //开启分页
            , cols: [[ //表头
                {
                    field: 'type',
                    title: '上报类型',
                    fixed: 'left',
                    sort: true,
                    templet: function (d) {
                        if (d.type == 0) {
                            return "群众上报"
                        } else if (d.type == 1) {
                            return "日常巡查"
                        } else {
                            return "未列出"
                        }
                    }
                }, {
                    field: 'status',
                    title: '处理结果',
                    sort: true,
                    templet: function (d) {
                        if (d.status == 0) {
                            return "未处理"
                        } else if (d.status == 1) {
                            return "已处理"
                        } else {
                            return "未列出"
                        }
                    }
                }, {
                    field: 'userPhone',
                    title: '上报用户联系方式',
                    width: 150
                }, {
                    field: 'userName',
                    title: '上报用户姓名',
                    width: 120
                }, {
                    field: 'city',
                    title: '城市'
                }, {
                    field: 'district',
                    title: '县区'
                }, {
                    field: 'street',
                    title: '地址'
                }, {
                    field: 'streetNumber',
                    title: '门牌号'
                }, {
                    field: 'hazardType',
                    title: '灾害类型',
                    templet: function (d) {
                        if (d.hazardType == -1) {
                            return "未知"
                        } else if (d.hazardType == 0) {
                            return "小型"
                        } else if (d.hazardType == 1) {
                            return "中型"
                        } else if (d.hazardType == 2) {
                            return "大型"
                        } else if (d.hazardType == 3) {
                            return "特大型"
                        } else {
                            return "未列出"
                        }
                    }
                }, {
                    field: 'hazardType',
                    title: '灾害类型',
                    templet: function (d) {
                        if (d.hazardType == -1) {
                            return "未知"
                        } else if (d.hazardType == 0) {
                            return "不稳定斜坡"
                        } else if (d.hazardType == 1) {
                            return "滑坡"
                        } else if (d.hazardType == 2) {
                            return "崩塌"
                        } else if (d.hazardType == 3) {
                            return "泥石流"
                        } else if (d.hazardType == 4) {
                            return "地面塌陷"
                        } else if (d.hazardType == 5) {
                            return "地裂缝"
                        } else if (d.hazardType == 6) {
                            return "地面沉降"
                        } else {
                            return "未列出"
                        }
                    }
                }, {
                    field: 'hazardLevel',
                    title: '灾害等级',
                    templet: function (d) {
                        if (d.hazardLevel == -1) {
                            return "未知"
                        } else if (d.hazardLevel == 0) {
                            return "一般"
                        } else if (d.hazardLevel == 1) {
                            return "较大"
                        } else if (d.hazardLevel == 2) {
                            return "重大"
                        } else if (d.hazardLevel == 3) {
                            return "特大"
                        } else {
                            return "未列出"
                        }
                    }
                }, {
                    field: 'hazardScale',
                    title: '灾害规模',
                    templet: function (d) {
                        if (d.hazardScale == -1) {
                            return "未知"
                        } else if (d.hazardScale == 0) {
                            return "小型"
                        } else if (d.hazardScale == 1) {
                            return "中型"
                        } else if (d.hazardScale == 2) {
                            return "大型"
                        } else if (d.hazardScale == 3) {
                            return "特大型"
                        } else {
                            return "未列出"
                        }
                    }
                }, {
                    field: 'hazardStatus',
                    title: '灾害状态',
                    templet: function (d) {
                        if (d.hazardStatus == 0) {
                            return "未治理"
                        } else if (d.hazardStatus == 1) {
                            return "已治理"
                        } else if (d.hazardStatus == 2) {
                            return "已搬迁"
                        } else if (d.hazardStatus == 3) {
                            return "已消亡"
                        } else {
                            return "未列出"
                        }
                    }
                }, {
                    field: 'hazardDetail',
                    title: '灾害描述'
                }, {
                    field: 'feedback',
                    title: '反馈信息'
                }, {
                    field: 'inspectionStatus',
                    title: '巡查状态',
                    templet: function (d) {
                        if (d.inspectionStatus == 0) {
                            return "正常"
                        } else if (d.inspectionStatus == 1) {
                            return "不正常"
                        } else {
                            return "未列出"
                        }
                    }
                }, {
                    field: 'inspectionDetail',
                    title: '巡查反馈信息'
                }, {
                    field: 'remark',
                    title: '备注'
                }, {
                    field: 'operatorName',
                    title: '处理人名字'
                }
            ]]
        });   //监听行单击事件
        table.on('rowDouble(record)', function (obj) {
            var arr = obj.data.positionData.split(',');
            var lat = arr[0].substring(5, arr[0].length)
            var lng = arr[1].substring(4, arr[1].length - 1)
            var bd_latlng = wgs84_to_bd(lng, lat);

            layer.open({
                type: 2,
                title: "定位",
                area: ['60%', '80%'],
                content: "/dingwei?lat=" + bd_latlng[1] + "&lng=" + bd_latlng[0]
            });


        });


    });


}

function wgs84_to_bd(lng, lat) {
    var gcj02_latlng = coordtransform.wgs84togcj02(lng, lat);
    return coordtransform.gcj02tobd09(gcj02_latlng[0], gcj02_latlng[1]);
}
